<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
  <title>Purple Admin</title>
  <!-- plugins:css -->
  <link rel="stylesheet" href="vendors/iconfonts/mdi/css/materialdesignicons.min.css"/>
  <link rel="stylesheet" href="vendors/css/vendor.bundle.base.css"/>

  <!-- endinject -->
  <!-- plugin css for this page -->

  <!-- End plugin css for this page -->
  <!-- inject:css -->
  <link rel="stylesheet" href="css/style.css"/>
  <!-- endinject -->
  <link rel="shortcut icon" href="images/favicon.png" />

</head>

<body>
<div class="row">
  <div class="col-lg-12 stretch-card">
    <div class="card">
      <div class="card-body">
        <h4 class="card-title">首页/客户档案管理/会员等级管理</h4>
        <p class="card-description">
          会员等级管理
        </p>
        <button  type="button" class="btn btn-inverse-danger btn-icon" data-toggle="modal" data-target="#myModal">添加</button>
        <table class="table table-bordered">
          <thead>
          <tr>
            <th>会员等级</th>
            <th>默认会员等级</th>
            <th>成长值满足点</th>
            <th>每借贷金额</th>
            <th>评价奖励</th>
            <th>备注</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr class="table-info" th:each="vip:${vips}">
<!--              <td id="vipid"  th:text="${vip.id}"></td>-->
              <td th:text="${vip.member_name}"></td>
              <td th:if="${vip.default_level} == 1">
                <input type="radio" th:attr="id=${vip.id}"   th:attrappend="name=${vip.id}" value="1"  th:onclick="'javascript:uprank('+${vip.id}+')'" checked="checked"/>开启
                <input type="radio" th:attr="id=${vip.id}+'1'"   th:attrappend="name=${vip.id}" value="0" th:onclick="'javascript:uprank('+${vip.id}+')'"/>关闭
              </td>
              <td th:if="${vip.default_level} == 0">
                <input type="radio" th:attr="id=${vip.id}"   th:attrappend="name=${vip.id}" value="1"  th:onclick="'javascript:uprank('+${vip.id}+')'"/>开启
                <input type="radio" th:attr="id=${vip.id}+'1'"   th:attrappend="name=${vip.id}" value="0" th:onclick="'javascript:uprank('+${vip.id}+')'" checked="checked"/>关闭
              </td>
              <td th:text="${vip.growth_value}"></td>
              <td th:text="|${vip.loan_amount}代币/元|"></td>
              <td th:text="|${vip.evaluate_award}代币/条|"></td>
              <td th:text="${vip.remark}"></td>
              <td >
                <button type="button" class="btn btn-inverse-danger btn-icon" data-toggle="modal" data-target="#myModal1" th:onclick="'javascript:addid('+${vip.id}+','+'\''+${vip.member_name}+'\''+','+${vip.growth_value}+','+${vip.loan_amount}+','+${vip.evaluate_award}+','+'\''+${vip.remark}+'\''+','+${vip.default_level}+','+${vip.signin_privilege}+','+${vip.evaluate_privilege}+','+${vip.vip_privilege}+','+${vip.member_privilege}+','+${vip.birthday_privilege}+')'">编辑</button>
                <button type="button" class="btn btn-inverse-danger btn-icon" th:onclick="'javascript:del('+${vip.id}+')'">删除</button>
              </td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
            </div>
            <h4 class="modal-title text-center" id="myModalLabel1">修改会员类型</h4>
            <form class="forms-sample" id="editRoeFrom1" >
                <input type="hidden" id="editRoleId1" name="id" />
                <div class="modal-body">
                    <div class="form-group">
                        <label for="exampleInputNames1" class="text-left"><span class="s">*</span>会员等级名称：</label>
                        <input  type="text" name="member_name" required="required"  id="exampleInputNames1"/>
                    </div>
                    <div class="form-group">
                        <label for="cdId" class="text-left"><span class="s">*</span>成长值满足点：</label>
                        <input type="number" name="growth_value" required="required"  id="cdId1"/>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 col-form-label">设为默认会员等级：</label>
                        <div style="width:10px ; display: inline-block"  class="col-sm-4">
                            <div class="form-check">
                                <label class="form-check-label">
                                    <input type="radio" class="form-check-input" name="default_level" id="membershipRadioss1" value="1" />
                                    是
                                    <i class="input-helper"></i></label>
                            </div>
                        </div>
                        <div style="display: inline-block" class="col-sm-5">
                            <div class="form-check">
                                <label class="form-check-label">
                                    <input type="radio" class="form-check-input" name="default_level" id="membershipRadioss2" value="0"/>
                                    否
                                    <i class="input-helper"></i></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="exampleInputEmails3"><span class="s">*</span>借贷放款金额：</label>
                    <input type="number" min="0" name="loan_amount" id="exampleInputEmails3" required="required" placeholder=""/>
                    <label>代币/元</label>
                </div>
                <div class="form-group">
                    <label>评价奖励：</label>
                    <input type="number" min="0"  name="evaluate_award" id="exampleInputCitys2"  placeholder=""/>
                    <label>代币/条</label>
                </div>
                <div class="form-group">
                    <label for="exampleInputCity1">备注：</label>
                    <textarea  name="remark" id="exampleInputCitys1" rows="4"></textarea>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">签到奖励特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="signin_privilege" id="membershipRadioss4" value="1" />
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="signin_privilege" id="membershipRadioss3" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">评价奖励特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="evaluate_privilege" id="membershipRadioss5" value="1" />
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="evaluate_privilege" id="membershipRadioss6" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">专享活动特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="vip_privilege" id="membershipRadioss7" value="1" />
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="vip_privilege" id="membershipRadioss8" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">会员专属特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="member_privilege" id="membershipRadioss9" value="1" />
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="member_privilege" id="membershipRadioss10" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">生日礼包特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="birthday_privilege" id="membershipRadioss11" value="1" />
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="birthday_privilege" id="membershipRadioss12" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" id="editBtn1" class="btn btn-primary" data-dismiss="modal" onclick="updInfo()">提交
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
            </div>
            <h4 class="modal-title text-center" id="myModalLabel">添加会员类型</h4>
            <form class="forms-sample" id="editRoeFrom" >
                <input type="hidden" id="editRoleId" name="rId" value="0"/>
                <div class="modal-body">
                    <div class="form-group">
                        <label for="exampleInputName1" class="text-left"><span class="s">*</span>会员等级名称：</label>
                        <input  type="text" name="member_name" required="required"  id="exampleInputName1"/>
                    </div>
                    <div class="form-group">
                        <label for="cdId" class="text-left"><span class="s">*</span>成长值满足点：</label>
                        <input type="number" name="growth_value" required="required"  id="cdId"/>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 col-form-label">设为默认会员等级：</label>
                        <div style="width:10px ; display: inline-block"  class="col-sm-4">
                            <div class="form-check">
                                <label class="form-check-label">
                                    <input type="radio" class="form-check-input" name="default_level" id="membershipRadios1" value="1" checked=""/>
                                    是
                                    <i class="input-helper"></i></label>
                            </div>
                        </div>
                        <div style="display: inline-block" class="col-sm-5">
                            <div class="form-check">
                                <label class="form-check-label">
                                    <input type="radio" class="form-check-input" name="default_level" id="membershipRadios2" value="0"/>
                                    否
                                    <i class="input-helper"></i></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                <label for="exampleInputEmail3"><span class="s">*</span>借贷放款金额：</label>
                <input type="number" min="0" name="loan_amount" id="exampleInputEmail3" required="required" placeholder=""/>
                <label>代币/元</label>
                </div>
                <div class="form-group">
                    <label>评价奖励：</label>
                    <input type="number" min="0"  name="evaluate_award" id="exampleInputCity2"  placeholder=""/>
                    <label>代币/条</label>
                </div>
                <div class="form-group">
                    <label for="exampleInputCity1">备注：</label>
                    <textarea  name="remark" id="exampleInputCity1" rows="4"></textarea>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">签到奖励特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="signin_privilege" id="membershipRadios4" value="1" checked=""/>
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="signin_privilege" id="membershipRadios3" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">评价奖励特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="evaluate_privilege" id="membershipRadios5" value="1" checked=""/>
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="evaluate_privilege" id="membershipRadios6" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">专享活动特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="vip_privilege" id="membershipRadios7" value="1" checked=""/>
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="vip_privilege" id="membershipRadios8" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">会员专属特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="member_privilege" id="membershipRadios9" value="1"  checked=""/>
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="member_privilege" id="membershipRadios10" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 col-form-label">生日礼包特权：</label>
                    <div style="width:10px ; display: inline-block"  class="col-sm-4">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="birthday_privilege" id="membershipRadios11" value="1"  checked=""/>
                                是
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                    <div style="display: inline-block" class="col-sm-5">
                        <div class="form-check">
                            <label class="form-check-label">
                                <input type="radio" class="form-check-input" name="birthday_privilege" id="membershipRadios12" value="0"/>
                                否
                                <i class="input-helper"></i></label>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" id="editBtn" class="btn btn-primary" data-dismiss="modal" onclick="add()">提交
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
  <!-- container-scroller -->
  <!-- plugins:js -->

  <script src="vendors/js/vendor.bundle.base.js"></script>
  <script src="js/jquery-3.2.1.min.js"></script>

<!-- plugins:js -->
<script src="vendors/js/vendor.bundle.base.js"></script>
<script src="vendors/js/vendor.bundle.addons.js"></script>
<!-- endinject -->
<!-- Custom js for this page-->
<script src="js/dashboard.js"></script>
<!-- End custom js for this page-->
  <script type="text/javascript">
      // 删除会员
    function del(id) {
      var idnum = id;
        // alert(idnum);
        $.ajax({
            url: '/hxvip/del/' + id + "",
            type: 'get',
            data: '',
            dataType: 'json',
            success: function (data) {
                alert("删除成功！");
                window.location.reload();
            },
            error : function() {
                alert("异常！");
            }
        });
    }
    //修改默认会员等级
      function uprank(id) {
        //取某一行修改的值和id
          var val = $('input[name='+id+']:checked').val();
            //alert(val);
          $.ajax({
              url:"/hxvip/updrank",
              data:{"id":id,"rank":val},
              dataType:"json",
              type:"GET",
              success: function (date) {
                  window.location.reload();
              },
              error : function() {
                  alert("异常！");
              }
          })
      }

        //添加会员
      function add() {
            //添加会员
            var data=$('#editRoeFrom').serialize();
            var submitData=decodeURIComponent(data,true);
            $.ajax({
                url:"/hxvip/addVip",
                data:submitData,
                dataType:"json",
                type:"GET",
                success: function (date) {
                    window.location.reload();
                },
                error : function() {
                    alert("异常！");
                }
            })
      }
      function addid(id,member_name,growth_value,loan_amount,evaluate_award,remark,default_level,signin_privilege,evaluate_privilege,vip_privilege,member_privilege,birthday_privilege) {
          $("#editRoleId1").val(id);
          $("#exampleInputNames1").val(member_name);
          $("#cdId1").val(growth_value);
          $("#exampleInputEmails3").val(loan_amount);
          $("#exampleInputCitys2").val(evaluate_award);
          $("#exampleInputCitys1").val(remark);
         if(default_level == 1){
             $("input[id=membershipRadioss1]").prop("checked",true);
         }else {
             $("input[id=membershipRadioss2]").prop("checked",true);
         }
          if(signin_privilege == 1){
              $("input[id=membershipRadioss4]").prop("checked",true);
          }else {
              $("input[id=membershipRadioss3]").prop("checked",true);
          }
          if(evaluate_privilege == 1){
              $("input[id=membershipRadioss5]").prop("checked",true);
          }else {
              $("input[id=membershipRadioss6]").prop("checked",true);
          }
          if(vip_privilege == 1){
              $("input[id=membershipRadioss7]").prop("checked",true);
          }else {
              $("input[id=membershipRadioss8]").prop("checked",true);
          }
          if(member_privilege == 1){
              $("input[id=membershipRadioss9]").prop("checked",true);
          }else {
              $("input[id=membershipRadioss10]").prop("checked",true);
          }
          if(birthday_privilege == 1){
              $("input[id=membershipRadioss11]").prop("checked",true);
          }else {
              $("input[id=membershipRadioss12]").prop("checked",true);
          }

      }
      function updInfo() {
          // 修改会员
          var data=$('#editRoeFrom1').serialize();
          var submitData=decodeURIComponent(data,true);
          // var fm = new FormData($( "#editRoeFrom1" )[0]);
          var val = $("#editRoleId1").val();
          // fm.set("id",val);
          $.ajax({
              url:"/hxvip/updInfo",
              data:submitData,
              dataType:"json",
              type:"GET",
              success: function (date) {
                  window.location.reload();
              },
              error : function() {
                  alert("异常！");
              }
          })
      }




  </script>
  <script src="vendors/js/vendor.bundle.addons.js"></script>
  <!-- endinject -->
  <!-- Plugin js for this page-->
  <!-- End plugin js for this page-->
  <!-- inject:js -->
  <script src="js/off-canvas.js"></script>
  <script src="js/misc.js"></script>
  <!-- endinject -->
  <!-- Custom js for this page-->
  <!-- End custom js for this page-->
</body>

</html>
